// D3D9Camera.cpp

#include "stdafx.h"

#include "D3D9Camera.h"

CD3D9Camera::CD3D9Camera()
{
	m_vEye = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	m_vLookat = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	m_vUpVec = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
}

CD3D9Camera::~CD3D9Camera()
{

}

void CD3D9Camera::Setup(float pos_x, float pos_y, float pos_z,
						float look_x, float look_y, float look_z, 
						float up_x, float up_y, float up_z)
{
	this->SetPos(pos_x, pos_y, pos_z);
	this->SetLookAt(look_x, look_y, look_z);
	m_vUpVec.x = up_x; m_vUpVec.y = up_y; m_vUpVec.z = up_z;
}

void CD3D9Camera::SetPos(float x, float y, float z)
{
	m_vEye.x = x;
	m_vEye.y = y;
	m_vEye.z = z;
}

void CD3D9Camera::SetLookAt(float x, float y, float z)
{
	m_vLookat.x = x;
	m_vLookat.y = y;
	m_vLookat.z = z;
}

void CD3D9Camera::SetFarPlane(float fValue)
{
	m_fFarPlane = fValue;
}

void CD3D9Camera::SetNearPlane(float fValue)
{
	m_fNearPlane = fValue;
}

void CD3D9Camera::SetViewport(int nWidth, int nHeight)
{
	m_fAspect = nWidth / static_cast<float>(nHeight);
}

void CD3D9Camera::SetFov(float fFov)
{
	m_fFov = fFov;
}

D3DXVECTOR3 CD3D9Camera::GetDir(void)
{
	D3DXVECTOR3 vOut;
	D3DXVECTOR3 vDir = m_vLookat - m_vEye;
	D3DXVec3Normalize(&vOut, &vDir);
	return vOut;
}

D3DXVECTOR3 CD3D9Camera::GetPos(void)
{
	return m_vEye;
}